package com.example.demo.controller.game;

import lombok.AllArgsConstructor;
import lombok.Data;

// 控制飞机的命令格式
@Data
@AllArgsConstructor
public class PlaneCmd {
    public int x, y;
    public String thrust;

    public PlaneCmd(double x, double y, String thrust) {
        this.x = (int) Math.round(x);
        this.y = (int) Math.round(y);
        this.thrust = thrust;
    }

    public PlaneCmd(String x, String y, String thrust) {
        try {
            this.x = Integer.parseInt(x);
            this.y = Integer.parseInt(y);
            this.thrust = thrust;
        } catch (NumberFormatException e) {
            System.out.println("x = [" + x + "]");
            System.out.println("y = [" + y + "]");
            e.printStackTrace();
        }
    }
}
